import {searchApi} from "../../../services/api"

export default {
  namespace: 'search',

  state: {
    data:{
      total: 0,
      items: []
    }
  },

  effects: {
    *search({payload}, {call, put}) {
      const response = yield call(searchApi, payload);
      yield put({
        type: 'saveArticleData',
        payload: response,
      });
    },
  },

  reducers: {
    saveArticleData(state, action) {
      return {
        ...state,
        data: action.payload,
      };
    },
  }
}
